hs.graphicsDir = '/js/highslide/graphics/';
hs.wrapperClassName = 'wide-border';
hs.showCredits = false;
hs.wrapperClassName = 'draggable-header';
hs.allowMultipleInstances = false;
hs.cacheAjax = false;

var selectedCount = 0;

function InviteFriends(obj)
{		
	return hs.htmlExpand(obj, {objectType: 'ajax', headingText: 'Приглашение друзей', minWidth: 480, minHeight:800, src:'/ajax/load-friends'} );
}

function onFriendClick(obj)
{
	if($(obj).hasClass('flist_cell_on'))
	{
		$(obj).removeClass('flist_cell_on');
		$(obj).addClass('flist_cell');
		selectedCount--;
		$('#privacy_box_list_selected_count').html(selectedCount);		
	}
	else
	{		
		$(obj).removeClass('flist_cell');
		$(obj).removeClass('flist_cell_over');
		$(obj).addClass('flist_cell_on');
		selectedCount++;
		$('#privacy_box_list_selected_count').html(selectedCount);		
	}
}

function flistOver(obj)
{
	if(!$(obj).hasClass('flist_cell_on')){
			$(obj).removeClass('flist_cell');
			$(obj).addClass('flist_cell_over');
	}	
}

function flistOff(obj)
{
	if(!$(obj).hasClass('flist_cell_on')){
				$(obj).removeClass('flist_cell_over');
				$(obj).addClass('flist_cell');
	}
}

function showIndex()
{
		if($('#privacy_box_list_tab').hasClass('t_filter_off'))		
		{
			$('.privacy_box_flist_data div.flist_cell').show();
		}		
		
		$('#privacy_box_list_tab').removeClass('t_filter_off');
		$('#privacy_box_list_tab').addClass('t_filter_selected');
		
		$('#privacy_box_list_selected_tab').addClass('t_filter_off');
		$('#privacy_box_list_selected_tab').removeClass('t_filter_selected');		
}

function showSelected()
{
		if($('#privacy_box_list_selected_tab').hasClass('t_filter_off'))		
		{
			$('.privacy_box_flist_data div.flist_cell').hide();
		}
		
		$('#privacy_box_list_selected_tab').removeClass('t_filter_off');
		$('#privacy_box_list_selected_tab').addClass('t_filter_selected');
		
		$('#privacy_box_list_tab').addClass('t_filter_off');
		$('#privacy_box_list_tab').removeClass('t_filter_selected');		
}


function sendInvites(obj)
{
	hs.close(obj);
		
	var friends = [];
	$('.privacy_box_flist_data div.flist_cell_on').each(function(index, data){
		friends[index] = $(data).attr('id');
	});	
	
	$.post('/ajax/send-invites', {id_group: $('#id_group').val(), data: implode(',', friends)}, function(data){
		if(data == 'OK')		
			hs.htmlExpand(null, {contentId: 'InviteFriendsMessage', headingText: 'Приглашение друзей', minWidth: 480, minHeight:800} );	
		else alert(data);	
	});		
}

function closePopup(obj)
{
	hs.close(obj);
}
